One shortfall of example-based unit tests is that they only test known examples. Property-based testing lets you test against randomized inputs if you can specify properties that must be true of the code's behavior ("invariants"). You also test your function against extreme-values (aka, fuzzing).
In this talk, will review some examples of property-based tests using the Hypothesis library. We will demo automated test generation ("ghostwriting" tests) to make writing tests easier. We will demo stateful testing to confirm that all possible states are valid in a program. Lastly, we will end with parting thoughts on how to specify properties. Often, the tricky part with PBT is knowing what to test! Since we are using randomized input, we need to specify properties that should hold true across all outputs.
https://www.chipy.org
Chicago Python User Group known as ChiPy was founded in 2003. We are an active user group organized around the Python.programming language. Our meetings are open to all of all proficiency and experience levels.
Produced by NDV: https://youtube.com/channel/UCQ7dFBzZGlBvtU2hCecsBBg?sub_confirmation=1